.TH std::vector::flip 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::vector::flip \- std::vector::flip

.SH Synopsis
   Defined in header <vector>
   void flip();                \fI(until C++20)\fP
   constexpr void flip();      \fI(since C++20)\fP

   Toggles each bool in the vector (replaces with its opposite value).

.SH Parameters

   \fI(none)\fP

.SH Return value

   \fI(none)\fP

.SH Example


// Run this code

 #include <iostream>
 #include <vector>

 void print(const std::vector<bool>& vb)
 {
     for (const bool b : vb)
         std::cout << b;
     std::cout << '\\n';
 }

 int main()
 {
     std::vector<bool> v{0, 1, 0, 1};
     print(v);
     v.flip();
     print(v);
 }

.SH Output:

 0101
 1010

.SH See also

   operator[] access specified element
              \fI(public member function of std::vector<T,Allocator>)\fP
   flip       toggles the values of bits
              \fI(public member function of std::bitset<N>)\fP
